package com.rocketmq.consumer;

import com.alibaba.fastjson2.JSONObject;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 顺序消息(group不能重复，否则会接收不到消息)
 * @author ytj
 * @date 2024/10/11 11:08
 */
@Component
@RocketMQMessageListener(consumerGroup = "order-product",topic = "order-topic",consumeMode = ConsumeMode.ORDERLY)
public class OrderTest implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt messageExt){
        System.out.println("接收消息为:"+new String(messageExt.getBody()));
    }
}
